package com.pro.back.controller;

import com.pro.back.bean.Duser;
import com.pro.back.bean.common.ApiRes;
import com.pro.back.bean.po.UserPO;
import com.pro.back.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: jingwenjuan
 * @Description:
 * @Date: 2025-04-19
 */
@Api(tags = "用户相关")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("登录")
    @PostMapping("/login")
    public ApiRes login(@RequestBody Duser duser) {
        return userService.login(duser);
    }

    @ApiOperation("注册或编辑信息")
    @PostMapping("/register")
    public ApiRes register(@RequestBody Duser duser) {
        return userService.register(duser);
    }


    @ApiOperation("删除用户")
    @GetMapping("/delUser")
    public ApiRes delUser(Long id){
        return userService.delUser(id);
    }

    @ApiOperation("分页条件查询用户")
    @PostMapping("/selectAll")
    public ApiRes selectAll(@RequestBody UserPO po) {
        return userService.selectAll(po);
    }

    @GetMapping("/deviceBorrowStatus")
    @ApiOperation("设备借出及已还正常状态统计-扇形图")
    public ApiRes deviceBorrowStatus() {
        return userService.deviceBorrowStatus();
    }

    @ApiOperation("设备修理状态统计")
    @GetMapping("/deviceRepairStatus")
    public ApiRes deviceRepairStatus(){
        return userService.deviceRepairStatus();
    }

    @ApiOperation("人数最多的6个班级")
    @GetMapping("/peopleNumCount")
    public ApiRes peopleNumCount() {
        return userService.peopleNumCount();
    }

    @ApiOperation("设备最多的6个分类")
    @GetMapping("/deviceCount")
    public ApiRes deviceCount() {
        return userService.deviceCount();
    }


}
